package com.saishi.servlet;

import com.saishi.dao.DaoImpl.YueYDaoImpl;

import com.saishi.dao.YueYonHu;

import com.saishi.entity.*;


import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.List;

@WebServlet("/yuezuoyei/*")
public class ServletYueZuoYei extends BaseServlet {
    YueYonHu styu=new YueYDaoImpl();

    protected void fan1(HttpServletRequest request, HttpServletResponse response) throws  ServletException, IOException, SQLException , ParseException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html");
        HttpSession Session=request.getSession();

        String name1 =request.getParameter("admin");
        String  phone = request.getParameter("psaa");
        System.out.println(name1);
        System.out.println(phone);
        PrintWriter out = response.getWriter();
        User ir=null;
       ir= styu.dr(name1,phone);
       // System.out.println(ir);
        if (ir == null) {
            System.out.println("失败" +ir);
            String sy="失败";
            request.setAttribute("a1sd",sy);
           //
            request.getRequestDispatcher("/dr.jsp").forward(request, response);
        } else {

           Session.setAttribute("lif0",ir);
            System.out.println("成功" +ir);
//            request.getRequestDispatcher("/LaoShiBj.jsp").forward(request, response);
//            Session.setAttribute("lif0",ir);
            request.getRequestDispatcher("/LaoShiBj.jsp").forward(request,response);


        }

    }
    protected void fan2(HttpServletRequest request, HttpServletResponse response) throws  ServletException, IOException, SQLException , ParseException {
        request.setCharacterEncoding("utf-8");
        HttpSession Session=request.getSession();
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html");
        String name1 =request.getParameter("admin1");
        String name2=request.getParameter("antyt1rt");
        int st=Integer.parseInt(name1);
        System.out.println(st);

      List<Classes> lsbjcx12=styu.lsbjcx(st);
        System.out.println(lsbjcx12);
        Session.setAttribute("lsbjcx12",lsbjcx12);
        request.getRequestDispatcher("/LaoShiBj.jsp").forward(request,response);
    }
    protected void fan3(HttpServletRequest request, HttpServletResponse response) throws  ServletException, IOException, SQLException , ParseException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html");
        HttpSession Session=request.getSession();
        String antybj =request.getParameter("antybj");
        String bennian =request.getParameter("bennian");
        String antyt1rt1=request.getParameter("antyt1rt1");
//        int  ddbh = Integer.parseInt(bennian);
       String bain1 =request.getParameter("bain1");
        System.out.println("时间"+bennian);
        System.out.println("时间"+bain1);
        System.out.println("班级"+antybj);
        Hrsrqi sj=styu.SJ(antybj);
        System.out.println(sj);

//        int   bain2=Integer.parseInt(bain1);
//        System.out.println(antybj);

//        List<Classes> lsbjcx12=styu.lsbjcx(st);
//        System.out.println(lsbjcx12);
//
//    if(bennian.equals(bain1)){
       // System.out.println("成功");
          Hrsyue lsbw=styu.SJ1(antyt1rt1);
           Session.setAttribute("dbt1",lsbw);
        System.out.println(lsbw);
//       }else {
//        System.out.println("失败");
           int dbt=12;
           Session.setAttribute("dbt",dbt);
//       }

        Session.setAttribute("antybj",antybj);
       request.setAttribute("lsbw",lsbw);
        Session.setAttribute("sj",sj);
       request.setAttribute("bennian",bennian);
        Session.setAttribute("bjui",antyt1rt1);
        request.setAttribute("bain1",bain1);
        Session.setAttribute("bain2rt",bain1);
        request.getRequestDispatcher("/LaoShiBj.jsp").forward(request,response);
    }
    protected void fan4(HttpServletRequest request, HttpServletResponse response) throws  ServletException, IOException, SQLException , ParseException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html");
        HttpSession Session=request.getSession();
        String bj =request.getParameter("bj1");
        String nian =request.getParameter("nian1");
        String yue =request.getParameter("yue1");
        String chisr =request.getParameter("chis");

        List<HRSKaoQinQinKuaN>  HRSKaoQinQinKuaN;
//        int ci=Integer.parseInt(chisr);
        if(chisr!=null){
            String bjs1 =request.getParameter("bj1");
            String nians1 =request.getParameter("nian1");
            String yues1 =request.getParameter("yue1");
            String chisrs1=request.getParameter("chis");
             int   chiss1=styu.count(bj);
             int cis1=Integer.parseInt(chisr);
           HRSKaoQinQinKuaN=styu.SKaoQinQinKuaN(bj, nian,yue);
            Session.setAttribute("nian",nians1);
            Session.setAttribute("yue",yues1);
            request.setAttribute("cishs",chiss1);
            List<HrsBjtxcx> bjcx=styu.Banjitx(bjs1,cis1);
            request.setAttribute("bjcx",bjcx);
            request.setAttribute("HRSKaoQinQinKuaN",HRSKaoQinQinKuaN);
            System.out.println("th2  "+"n"+nian+"y"+yue+"c"+cis1);
            request.getRequestDispatcher("/LaoShiBj.jsp").forward(request,response);
        }else{
            int chis=styu.count(bj);
            System.out.println(chis);
            List<HrsBjtxcx> bjcx=styu.Banjitx(bj,1);
             HRSKaoQinQinKuaN=styu.SKaoQinQinKuaN(bj, nian,yue);
           Session.setAttribute("nian",nian);
            Session.setAttribute("yue",yue);
            request.setAttribute("bjcx",bjcx);
            request.setAttribute("cishs",chis);
            request.setAttribute("HRSKaoQinQinKuaN",HRSKaoQinQinKuaN);
            System.out.println("th1  "+bj+"n"+nian+"y"+yue);
            request.getRequestDispatcher("/LaoShiBj.jsp").forward(request,response);
        }


    }
    protected void fan5(HttpServletRequest request, HttpServletResponse response) throws  ServletException, IOException, SQLException , ParseException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html");
        HttpSession Session=request.getSession();
        String d = request.getParameter("antr");//1
        String d1 = request.getParameter("ner");//1
        String d2 = request.getParameter("bjst");//1
        System.out.println(d1+""+d+""+d2);
        Session.setAttribute("idu",d);
        Session.setAttribute("uname",d1);
        Session.setAttribute("bj",d2);

            request.getRequestDispatcher("/uuu.jsp").forward(request,response);
        }
    protected void fan6(HttpServletRequest request, HttpServletResponse response) throws  ServletException, IOException, SQLException , ParseException {
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html");
        HttpSession Session=request.getSession();
        String d = request.getParameter("nid");//1
        int di = Integer.parseInt(d);
        String name = request.getParameter("nname");
        String date = request.getParameter("date");//2
        String cls = request.getParameter("cls");
        String message = request.getParameter("message");
        styu.addfind(di,date,message);
        System.out.println(d+"---"+name+"---"+date+"---"+cls+"--"+message);
     request.getRequestDispatcher("/LaoShiBj.jsp").forward(request,response);
      //response.sendRedirect("/examine/y/find?limt=1");
    }


}
